package com.example.xiao.httpprocessor.HttpProcessor

import android.content.Context
import com.android.volley.Request
import com.android.volley.RequestQueue
import com.android.volley.Response
import com.android.volley.toolbox.StringRequest
import com.android.volley.toolbox.Volley

class VolleyProcessor constructor(var context: Context): IHttpProcessor{

    init {
        mQueue = Volley.newRequestQueue(context)
    }

    companion object {
        private var mQueue: RequestQueue? = null
    }

    override fun post(url: String, params: Map<String, Any>,callback: ICallBack) {
        var stringRequest = StringRequest(Request.Method.POST, url,
                Response.Listener { callback.onSuccess(it) },
                Response.ErrorListener { callback.onFailure(it.toString()) })
        mQueue!!.add(stringRequest)
    }

}
